<!-- A beautiful app starts with a beautiful code :) -->

<!-- /userSpan/monitoringUserSpan -->

<!-- Header -->
<div class="main-window-segment header-segment bottom-padded">
    <div class="container-fluid">
        <div class="row">

            <div class="col-lg-10 col-md-6 col-sm-12">
                <h2>Monitoring Pergantian User</h2>
            </div>
			<div class="col-lg-1 col-md-3 col-sm-12" style="padding-top: 20px;">
                <?php if(Session::get('role') == UMADMIN||Session::get('role') == KPPN||Session::get('role') == KANWIL) {?>
                <button type="button" class="btn btn-default fullwidth" data-toggle="modal" data-target="#modal-app-tambah"><span class="glyphicon glyphicon-headphones"></span> Tambah</button>
                <?php } ?>

            </div>
			<?php
			if (Session::get('role') == ADMIN || Session::get('role') == UMADMIN) {
                                           
					if (isset($this->d_kd_kppn)) {
						$kdkppn = $this->d_kd_kppn;
                    } else {
						$kdkppn = 'null';
                     }
                    if (isset($this->d_nip1)) {
                        $kdnip1 = $this->d_nip1;
                    } else {
                        $kdnip1 = 'null';
                    }
                    if (isset($this->d_nip2)) {
                        $kdnip2 = $this->d_nip2;
                    } else {
                        $kdnip2 = 'null';
                    }

                    if (isset($this->d_catatan)) {
                        $kdcatatan = $this->d_catatan;
                    } else {
                        $kdcatatan = 'null';
                    }
					
                    
                }
				if (Session::get('role') == KPPN) {

                    if (isset($this->d_kd_kppn)) {
                       $kdkppn = $this->d_kd_kppn;
                    } else {
                        $kdkppn = Session::get('id_user');
                    }
                    if (isset($this->d_nip1)) {
                        $kdnip1 = $this->d_nip1;
                    } else {
                        $kdnip1 = 'null';
                    }
                    if (isset($this->d_nip2)) {
                        $kdnip2 = $this->d_nip2;
                    } else {
                        $kdnip2 = 'null';
                    }

                    if (isset($this->d_catatan)) {
                        $kdcatatan = $this->d_catatan;
                    } else {
                        $kdcatatan = 'null';
                    }
					
                    //----------------------------------------------------		
                }
			?>
<!-- 			<div class="btn-group-sm">
                    <button type="button" class="btn btn-default dropdown-toggle fullwidth" data-toggle="dropdown" aria-expanded="false"><span class="glyphicon glyphicon-print"></span>&nbsp; Cetak <span class="caret"></span>
                    </button>
                          <ul class="dropdown-menu" role="menu">
                            <li><a href="<?php echo URL; ?>PDF/pergantianUser_PDF/<?php echo $kdkppn . "/" . $kdnip1 . "/" . $kdnip2 . "/" . $kdcatatan; ?>/PDF">PDF</a></li>
                            <li><a href="<?php echo URL; ?>PDF/pergantianUser_PDF/<?php echo $kdkppn . "/" . $kdnip1 . "/" . $kdnip2 . "/" . $kdcatatan; ?>/XLS">EXCEL</a></li>
                          </ul>
            </div> -->
            <div class="col-lg-1 col-md-3 col-sm-12" style="padding-top: 20px;">

                <button type="button" class="btn btn-default fullwidth" data-toggle="modal" data-target="#modal-app-filter"><span class="glyphicon glyphicon-filter"></span> Filter</button>

            </div>
        </div>

        <div class="row">

            <div class="col-md-6 col-sm-12">
<?php
if (isset($this->d_nama_kppn)) {
    foreach ($this->d_nama_kppn as $kppn) {
        echo $kppn->get_nama_user() . " (" . $kppn->get_kd_satker() . ")";
        $kode_kppn = $kppn->get_kd_satker();
    }
}

if (isset($this->d_nip1)) {
    echo "<br>NIP Semula : ".$this->d_nip1;
}

if (isset($this->d_nip2)) {
    echo "<br>NIP Menjadi : ".$this->d_nip2;
}
?>
            </div>

            <div class="col-md-6 col-sm-12 align-right">
                <?php
                // untuk menampilkan last_update
                if (isset($this->last_update)) {
                    foreach ($this->last_update as $last_update) {
                        echo "Update Data Terakhir (Waktu Server)<br/>" . $last_update->get_last_update() . " WIB";
                    }
                }
                ?>
            </div>

        </div>

    </div>
</div>

<div id="table-container" class="wrapper"style="font-size: 90%">
    <table class="footable align-center" >

        <thead>
            <tr>
                <th >No.</th>
                <?php if (Session::get('role') != KPPN) { ?>
                <th >KPPN</th>
                <?php } ?>
                <th >Nama, NIP, Email, Posisi<br>SEMULA</th>
                <th >Nama, NIP, Email, Posisi<br>MENJADI</th>
                <th >Jenis Pergantian</th>
                <th >No. Surat<br>PDF Surat</th>
                <th >Tanggal Awal<br>Status</th>
                <th >Tanggal Akhir<br>Status</th>
                <th >User</th>
                <th >Catatan</th>
                <th >Cek Data</th>
                <?php if (Session::get('role') == UMADMIN) {
                    echo "<th >Ubah</th>" ;
                } ?>
            </tr>
        </thead>

        <tbody>

<?php $no = 1; ?>

<?php if (isset($this->data)) { ?>

    <?php if (empty($this->data)) { ?>

                <td colspan=8 class="align-center">Tidak ada data.</td>

                <?php } else { ?>

                    <?php foreach ($this->data as $value) { ?>

                    <tr>
                        <td><?php echo $no++; ?></td>
                        <?php if (Session::get('role') != KPPN) { ?>
                        <td><?php echo $value->get_kode_unit()."<br>"; 
                            foreach ($this->kppn_list as $value1) {
                                if ($value->get_kode_unit() == $value1->get_kd_d_kppn()) {
                                    echo $value1->get_nama_user(); 
                                }
                            }
                            ?>
                        </td>
                        <?php } ?>
                        <td class="align-left"><?php echo $value->get_nama_usr_awal() . "<br>" . $value->get_nip_usr_awal() . "<br>" . $value->get_email_usr_awal() . "@depkeu.go.id<br>" . $value->get_posisi_user_awal() ;?></td>
                        <!--td ><?php //echo  ?></td-->
                        <!--td ><?php //echo $value->get_posisi_user_awal(); ?></td-->
                        <td class="align-left"><?php echo $value->get_nama_usr_pengganti() . "<br>" . $value->get_nip_usr_pengganti() . "<br>" . $value->get_email_usr_pengganti() . "@depkeu.go.id<br>" . $value->get_posisi_user_pengganti() ; ?></td>
                        <!--td ><?php //echo $value->get_posisi_user_pengganti(); ?></td-->
                        <td ><?php if ($value->get_status_pergantian() == "1") { echo "Sementara"; } elseif ($value->get_status_pergantian() == "0"){ echo "Permanen";} else {"aneh";};  ?></td>
                        <td >
                            <?php 
                                echo $value->get_surat() . "<br>";
                                if ($value->get_pdf_surat()==''){
                                    echo "file tidak ada ";
                                } else {
                                    echo "<a href = http://10.100.93.56/public/tes_upload/".$value->get_pdf_surat().".pdf>download</a>";
                                }
                            ?>
                        <td ><?php echo $value->get_tanggal_awal() . "<br>" . $value->get_status_setup_awal();  ?></td>
                        <td ><?php if ($value->get_status_pergantian() == "1") { echo $value->get_tanggal_akhir() . "<br>" . $value->get_status_setup_akhir();  } else { echo "-"; }?> </td>
                        <td ><?php echo $value->get_user_session();  ?></td>
                        <td class="align-left"><?php echo $value->get_catatan(); ?></td>
                        <td ><?php foreach ($this->posisi_user as $posisi) {
                                if ($value->get_posisi_user_awal() == $posisi->get_deskripsi_posisi()) {
                                    if ($posisi->get_flag() == "1"){
                                    //echo " " . $posisi->get_flag();
                                        ?> <a href="<?php echo URL; ?>userSpan/invoiceProses/<?php echo $value->get_kode_unit();?>">Cek Data</a>
                                    <?php } else {
                                        echo "OK";
                                    }
                                }
                            } ?>
                        
                        </td>
                        <?php if (Session::get('role') == UMADMIN) { ?>
                        <td ><a class="btn btn-default" data-toggle="modal" data-target="#modal-app-update<?php echo $value->get_no_id();?>" name="upd_d_user"><span class="glyphicon glyphicon-pencil"></span></a><!--&nbsp;<a href='#' class="btn btn-default"><span class="glyphicon glyphicon-trash">--></span></a></td>

                    </tr>

<!--Ubah Data-->
<div class="modal fade" id="modal-app-update<?php echo $value->get_no_id();?>" tabindex="-1" role="dialog" aria-labelledby="app-filter-label" aria-hidden="true">

    <div class="modal-dialog">

        <div class="modal-content">

            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">   <span aria-hidden="true">&times;</span><span class="sr-only">Tutup</span></button>
                <h4 class="modal-title" id="app-filter-label"><span class="glyphicon glyphicon-headphones"></span> Update Data</h4>

            </div>
<!--test--> <?php //echo "PDF Surat:" . $value->get_pdf_surat(); ?>
            
            <form id="filter-form" method="POST" action="pergantianUser" enctype="multipart/form-data">

                <div class="modal-body">

<?php if (isset($this->kppn_list)) { ?>
                        <input type="hidden" name="user_session" id="user_session" value="<?php echo Session::get('user'); ?>">
                        <input type="hidden" name="stats" id="stats" value="<?php echo $value->get_status_pergantian(); ?>">
                        <div id="warning0" class="alert alert-danger" style="display:none;"></div>

<!--<<<<<< .mine -->
                        <label>Jenis Pergantian: </label>&nbsp;<?php if ($value->get_status_pergantian() == '1') { echo "Sementara"; } elseif ($value->get_status_pergantian() == '0') { echo "Permanen"; } else { echo "-"; } ?><br>
                        <label>KPPN: </label>
<!--=======
                        <label>Jenis Pergantian: </label><?php //if($value->get_status_pergantian() == "0"){ echo " Permanen";} elseif($value->get_status_pergantian() == "1"){ echo " Sementara";}; ?><br>
                        <label>KPPN: </label>
>>>>>>> .r1361 -->

                        <select class="form-control" type="text" name="kdkppn" id="kdkppn0">

    <?php foreach ($this->kppn_list as $value1) { ?>

        <?php if ($value->get_kode_unit() == $value1->get_kd_d_kppn()) { ?>
                                    
                                    <option value="<?php echo $value1->get_kd_d_kppn(); ?>" selected><?php echo $value1->get_kd_d_kppn(); ?> | <?php echo $value1->get_nama_user(); ?></option>

                                <?php } else { ?>

                                    <option value="<?php echo $value1->get_kd_d_kppn(); ?>"><?php echo $value1->get_kd_d_kppn(); ?> | <?php echo $value1->get_nama_user(); ?></option>

        <?php } ?>

                            <?php } ?>

                        </select>

                        <?php } ?>
                    <div id="wnip0" class="alert alert-danger" style="display:none;"></div>
                    <label>NIP</label>
                    <div class="input-group" id="nip0" style="width: 100%">
                        <input class="form-control" type="text" name="nip1" id="nip_1" 
                               <?php //if (isset($this->nip1)) {echo $this->nip1; }?>
                               value="<?php echo $value->get_nip_usr_awal(); ?>">
                        <span class="input-group-addon">diganti</span>
                        <input class="form-control" type="text" name="nip2" id="nip_2" value="<?php echo $value->get_nip_usr_pengganti()?>">
                    </div>
                    
                    <label>Nama</label>
                    <div class="input-group" id="nama0" style="width: 100%">
                        <input class="form-control" type="text" name="nama1" id="nama_1" value="<?php echo $value->get_nama_usr_awal()?>">
                        <span class="input-group-addon">diganti</span>
                        <input class="form-control" type="text" name="nama2" id="nama_2" value="<?php echo $value->get_nama_usr_pengganti()?>">
                    </div>
                    
                    <label>Posisi</label>
                    <div class="input-group" id="posisi0" style="width: 100%">
                        <select class="form-control" type="text" name="posisi1" id="posisi_1">
                            <?php   foreach ($this->posisi_user as $posisi) {
                                    if ($value->get_posisi_user_awal() == $posisi->get_deskripsi_posisi()) { ?>
                                <option value="<?php echo $posisi->get_deskripsi_posisi(); ?>" selected><?php echo $posisi->get_deskripsi_posisi(); ?></option>
                            
                                <?php } else { ?>
                                <option value="<?php echo $posisi->get_deskripsi_posisi(); ?>"><?php echo $posisi->get_deskripsi_posisi(); ?></option>
                            <?php } ?>
                            <?php } ?>
                        </select>
                        
                        <span class="input-group-addon">diganti</span>
                        <select class="form-control" type="text" name="posisi2" id="posisi_2">
                            <?php   foreach ($this->posisi_user as $posisi) {
                                    if ($value->get_posisi_user_pengganti() == $posisi->get_deskripsi_posisi()) { ?>
                                <option value="<?php echo $posisi->get_deskripsi_posisi(); ?>" selected><?php echo $posisi->get_deskripsi_posisi(); ?></option>
                                <?php } else { ?>
                                <option value="<?php echo $posisi->get_deskripsi_posisi(); ?>"><?php echo $posisi->get_deskripsi_posisi(); ?></option>
                            <?php } ?>
                            <?php } ?>

                        </select>
                    </div>
                    
                    <div class='row'>
                        <div class="col-md-6">
                            <label>Email User Awal:</label>
                            <div class="input-group">
                                    <input class="form-control" type="text" name="email1" id="email_1" value="<?php echo $value->get_email_usr_awal()?>" aria-describedby="basic-addon2"><span class="input-group-addon" id="basic-addon2">@depkeu.go.id</span>
                            </div>
                            
                            <label>No. Surat:</label>
                            <input class="form-control" type="text" name="surat" id="surat0" size="18" value="<?php echo $value->get_surat()?>">
                            
                            <label>Tanggal Mulai: </label>
<!--<<<<<< .mine-->
                            <input class="form-control" type="text" name="tanggal_awal" id="tanggal_1" value="<?php echo $value->get_tanggal_awal(); ?>">
<!--=======
                            <input class="form-control" type="text" class="tanggal" name="tanggal_1" id="tanggal_1" value="<?php //echo $value->get_tanggal_awal(); ?>">
>>>>>>> .r1361 -->
                            
                            <?php $data = array("Proses", "Tunda", "Tolak", "Selesai")?>
                            <label>Status:</label>
                            <select class="form-control" type="text" name="status1" id="status_1">
                                <option value ="" selected>-- pilih --</option>
                                 <?php foreach ($data as $row) { ?>
                                <option value="<?php echo $row?>" <?php if ($value->get_status_setup_awal() == $row) { echo "selected"; }?>><?php echo $row?></option><?php }?>
                            </select>
                        </div>
                        <div class="col-md-6">
                            <label>Email User Pengganti: </label>
                            <div class="input-group">
                                    <input class="form-control" type="text" name="email2" id="email_2" value="<?php echo $value->get_email_usr_pengganti()?>" aria-describedby="basic-addon2"><span class="input-group-addon" id="basic-addon2">@depkeu.go.id</span>
                            </div>
                            
                            <label>Upload Surat (pdf):</label><br>
                            <input class="form-control" type="text" name="pdf_surat" id="pdf_surat" value="<?php echo $value->get_pdf_surat(); ?>" disabled>
                            <div id='permanenHide1'>
                            <label>Tanggal Selesai: </label>
<!--<<<<<< .mine-->
                            <input class="form-control" type="text" name="tanggal_akhir" id="tanggal_2" value="<?php echo $value->get_tanggal_akhir(); ?>"<?php if ($value->get_status_pergantian() == '0') { echo "disabled"; }?>>
<!--=======
                            <input class="form-control" type="text" class="tanggal" name="tanggal_2" id="tanggal_2" value="<?php echo $value->get_tanggal_akhir(); ?>">
>>>>>>> .r1361 -->
                            </div>
                            <div id='statusHide1'>
                            <label>Status Akhir:</label>
                            <select class="form-control" type="text" name="status2" id="status_2">
                                <option value ="" selected>-- pilih --</option> 
                                <?php foreach ($data as $row) { ?>
                                <option value="<?php echo $row?>" <?php if ($value->get_status_setup_akhir() == $row) { echo "selected"; }?>><?php echo $row?></option><?php }?>
                            </select>
                            </div>
                            </div>
                        </div>
                    <label >Catatan:</label>
                    
                    <input class="form-control" type="text" name="catatan" id="catatan0" size="18" value="<?php echo $value->get_catatan(); ?>">
                
<!--<<<<<< .mine-->
                    <input class="form-control" type="hidden" name="no_id" id="no_id" value="<?php echo $value->get_no_id(); ?>">
                    <input class="form-control" type="hidden" name="status_pergantian" id="status_pergantian" value="<?php echo $value->get_status_pergantian(); ?>">
                    <input class="form-control" type="hidden" name="user_session" id="user_session" value="<?php echo $value->get_user_session(); ?>">
<!--=======
                    <input class="form-control" type="hidden" name="no_id" id="no_id" size="18" value="<?php echo $value->get_no_id(); ?>">
                    
>>>>>>> .r1361-->
                    </div> <!--end modal body-->

                                <div class="modal-footer">
                    <button type="submit" name="update_d_user" id="update_d_user" class="btn btn-primary" style="width: 100%" onClick="return cek_upload2()">Kirim</button>
                </div>

            </form>

        </div>

    </div>

</div>
                        <?php } ?>

        <?php }  ?>

    <?php } ?>

<?php } else { ?>

            <td colspan=6 align="center" id="filter-first">Silahkan masukkan filter terlebih dahulu.</td>

        <?php } ?>

        </tbody>

    </table>
</div> <!--end table-->


<!-- Tambah Data -->
<div class="modal fade" id="modal-app-tambah" tabindex="-1" role="dialog" aria-labelledby="app-filter-label" aria-hidden="true">

    <div class="modal-dialog">

        <div class="modal-content">

            <div class="modal-header">

                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Tutup</span></button>
                <h4 class="modal-title" id="app-filter-label"><span class="glyphicon glyphicon-headphones"></span> Tambah Data</h4>

            </div>

            <form id="filter-form" method="POST" action="pergantianUser" enctype="multipart/form-data">

                <div class="modal-body">



                        <div id="warning-all" class="alert alert-danger" style="display:none;"></div>
                        <input type="hidden" name="user_session" id="user_session" value="<?php echo Session::get('user'); ?>">
                        
                        <label>Jenis Pergantian: </label>
                        <div class="row">
                            <?php $stats = array(array("id"=>"Permanen", "value"=>0), array("id"=>"Sementara", "value"=>1));
                            foreach($stats as $val){
                            ?>
                            
                        <div class="col-md-6"><input type="radio" name="status_pergantian" id="<?php echo $val['id'];?>" value="<?php echo $val['value'];?>" checked="<?php if ($this->status_pergantian == $val['value']) { echo "checked"; }?>"/>&nbsp; <?php echo $val['id'];?></div>
                            <?php }?>
                        <!--div class="col-md-6"><input type="radio" name="status_pergantian" id="permanen" value="1" />&nbsp; Permanen</div-->
                        </div><br>
                    
        <?php if (isset($this->kppn_list)) { ?>
                        <label>KPPN: </label>
    
                        <select class="form-control" type="text" name="kdkppn" id="kdkppn">

    <?php foreach ($this->kppn_list as $value1) { ?>

        <?php if ($this->kdkppn == $value1->get_kd_d_kppn()) { ?>

                                    <option value="<?php echo $value1->get_kd_d_kppn(); ?>" selected><?php echo $value1->get_kd_d_kppn(); ?> | <?php echo $value1->get_nama_user(); ?></option>

                                <?php } else { ?>

                                    <option value="<?php echo $value1->get_kd_d_kppn(); ?>"><?php echo $value1->get_kd_d_kppn(); ?> | <?php echo $value1->get_nama_user(); ?></option>

        <?php } ?>

                            <?php } ?>

                        </select>

                        <?php } ?>
                    
                    <!--div id="wnip" class="alert alert-danger" style="display:none;"></div-->
                    <label>NIP:</label>
                    <div class="input-group" id="nip" style="width: 100%">
                        <input class="form-control" type="text" class="nip1" name="nip1" id="nip1" 
                               value="<?php if (isset($this->nip1)) {echo $this->nip1; }?>">
                        <span class="input-group-addon">diganti</span>
                        <input class="form-control" type="text" class="nip2" name="nip2" id="nip2" value="<?php if (isset($this->nip2)) {
                            echo $this->nip2; } ?>">
                    </div>
                    
                    <label>Nama:</label>
                    <div class="input-group" id="nama" style="width: 100%">
                        <input class="form-control" type="text" class="nama1" name="nama1" id="nama1" value="<?php if (isset($this->nama1)) {
                            echo $this->nama1; } ?>">
                        <span class="input-group-addon">diganti</span>
                        <input class="form-control" type="text" class="nama2" name="nama2" id="nama2" value="<?php if (isset($this->nama2)) {
                            echo $this->nama2; } ?>">
                    </div>
                    
                    <label>Posisi:</label>
                    <div class="input-group" id="posisi" style="width: 100%">
                        <select class="form-control" type="text" name="posisi1" id="posisi1">
                            <?php   foreach ($this->posisi_user as $posisi) {
                                    if ($this->posisi1 == $posisi->get_deskripsi_posisi()) { ?>
                                <option value="<?php echo $posisi->get_deskripsi_posisi(); ?>" selected><?php echo $posisi->get_deskripsi_posisi(); ?></option>
                            
                                <?php } else { ?>
                                <option value="<?php echo $posisi->get_deskripsi_posisi(); ?>"><?php echo $posisi->get_deskripsi_posisi(); ?></option>
                            <?php } ?>
                            <?php } ?>
                        </select>
                        
                        <span class="input-group-addon">diganti</span>
                        <select class="form-control" type="text" name="posisi2" id="posisi2">
                            <?php   foreach ($this->posisi_user as $posisi) {
                                    if ($this->posisi2 == $posisi->get_deskripsi_posisi()) { ?>
                                <option value="<?php echo $posisi->get_deskripsi_posisi(); ?>" selected><?php echo $posisi->get_deskripsi_posisi(); ?></option>
                                <?php } else { ?>
                                <option value="<?php echo $posisi->get_deskripsi_posisi(); ?>"><?php echo $posisi->get_deskripsi_posisi(); ?></option>
                            <?php } ?>
                            <?php } ?>

                        </select>
                    </div>
                    
                    <div class='row'>
                        <div class="col-md-6">
                            <label>Email User Awal:</label>
                            <div class="input-group">
                                    <input class="form-control" type="text" class="email1" name="email1" id="email1" value="<?php if (isset($this->email1)) {
                            echo $this->email1;
                        } ?>" aria-describedby="basic-addon2"><span class="input-group-addon" id="basic-addon2">@depkeu.go.id</span>
                            </div>
                            
                            <label>No. Surat:</label>
                            <input class="form-control" type="text" name="surat" id="surat" size="18" value="<?php if (isset($this->surat)) {
                            echo $this->surat;
                        } ?>">
                            
                            <label>Tanggal Mulai: </label>
                            <input class="form-control" type="text" class="tanggal" name="tanggal_awal" id="tanggal_awal" value="<?php if (isset($this->tanggal_awal)) {
                            echo $this->tanggal_awal;
                        } ?>">
                            
                            <?php if(Session::get('role') == UMADMIN) {
                            $data = array("Proses", "Tunda", "Tolak", "Selesai")?>
                            <label>Status:</label>
                            <select class="form-control" type="text" name="status1" id="status1">
                                <option value ="" selected>-- pilih --</option>
                                 <?php foreach ($data as $row) { ?>
                                <option value="<?php echo $row?>" <?php if ($this->status1 == $row) { echo "selected"; }?>><?php echo $row?></option><?php }?>
                            </select>
                            <?php } elseif (Session::get('role') == KPPN){?> <input class="form-control" type="hidden" name="status1" id="status1" value="Tunda" ><?php }?>
                        </div>
                        <div class="col-md-6">
                            <label>Email User Pengganti: </label>
                            <div class="input-group">
                                    <input class="form-control" type="text" class="email2" name="email2" id="email2" value="<?php if (isset($this->email2)) {
                            echo $this->email2;
                } ?>" aria-describedby="basic-addon2"><span class="input-group-addon" id="basic-addon2">@depkeu.go.id</span>
                            </div>
                            
                            <label>Upload Surat (pdf):</label>
                            <input class="form-control" type="file" name="pdf_surat" id="pdf_surat" value="<?php if (isset($this->pdf_surat)) {
                            echo $this->pdf_surat;
                        } ?>">
                            <div id='permanenHide'>
                            <label>Tanggal Selesai: </label>
                            <input class="form-control" type="text" class="tanggal" name="tanggal_akhir" id="tanggal_akhir" value="<?php if (isset($this->tanggal_akhir)) {
                            echo $this->tanggal_akhir;
                } ?>">
                            </div>
                            <?php if(Session::get('role') == UMADMIN) {?>
                            <div id='statusHide'>
                            <label>Status Akhir:</label>
                            <select class="form-control" type="text" name="status2" id="status2">
                                <option value ="" selected>-- pilih --</option> 
                                <?php foreach ($data as $row) { ?>
                                <option value="<?php echo $row?>" <?php if ($this->status2 == $row) { echo "selected"; }?>><?php echo $row?></option><?php }?>
                            </select>
                            </div>
                            <?php } elseif (Session::get('role') == KPPN){?> <input class="form-control" type="hidden" name="status2" id="status2" value="Tunda" ><?php }?>
                        </div>
                    </div>

                    
                    <label>Catatan:</label>
                    
                    <input class="form-control" type="text" name="catatan" id="catatan" size="18" value="<?php if (isset($this->catatan)) {
                            echo $this->catatan;
                        } ?>">
                
        
                </div> <!--end modal body-->

                <div class="modal-footer">
                    <!--button type="submit" name="add_d_user" class="btn btn-primary" style="width: 100%" data-toggle="modal" onClick="return cek_upload()">Kirim</button-->
                    <div class='row'>
                        <div class="col-md-6"><button type="reset" class="btn btn-warning" style="width: 100%" value="Reset">Reset</button></div>
                        <div class="col-md-6"><button type="submit" name="add_d_user" class="btn btn-primary" style="width: 100%" data-toggle="modal" onClick="return cek_upload()">Kirim</button></div>
                    </div>
                    
                </div>

            

        </div>

    </div>

</div> <!--end modal tambah-->

<!--Modal Konfirm belum dipakai, bingung gimana makenya-->
<div class="modal fade" id="modal-app-konfirm" tabindex="-1" role="dialog" aria-labelledby="app-filter-label" aria-hidden="true">

    <div class="modal-dialog">

        <div class="modal-content">

            <div class="modal-header">

                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Tutup</span></button>
                <h4 class="modal-title" id="app-filter-label"><i class="fa fa-question"></i> Konfirmasi</h4>
            </div>
            <div class="modal-body" align=''>
                Yakin Anda akan mengunggah data ini? Data yang telah diunggah tidak dapat diubah.
            </div>
            <div class="modal-footer">
                <button type="submit" name="add_d_user" class="btn btn-primary" style="width: 100%" onClick="">Yakin</button>
            </div>
            </form>
        </div>
    </div>
</div>

<!--end Modal Konfirm-->

<!-- FilterForm -->
<div class="modal fade" id="modal-app-filter" tabindex="-1" role="dialog" aria-labelledby="app-filter-label" aria-hidden="true">

    <div class="modal-dialog">

        <div class="modal-content">

            <div class="modal-header">

                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Tutup</span></button>
                <h4 class="modal-title" id="app-filter-label"><span class="glyphicon glyphicon-filter"></span> Filter Data</h4>

            </div>

            <form id="filter-form" method="POST" action="pergantianUser" enctype="multipart/form-data">

                <div class="modal-body">
                    <?php if (isset($this->kppn_list)) { ?>

                        <div id="wkdkppn" class="alert alert-danger" style="display:none;"></div>
                        <label class="isian">Kode KPPN: </label>

                        <select class="form-control" type="text" name="kdkppn" id="kdkppn">
                        <option value="SEMUAKPPN" selected>SEMUA KPPN</option>
    <?php foreach ($this->kppn_list as $value1) { ?>

        <?php if ($kode_kppn == $value1->get_kd_d_kppn()) { ?>

                                    <option value="<?php echo $value1->get_kd_d_kppn(); ?>" selected><?php echo $value1->get_kd_d_kppn(); ?> | <?php echo $value1->get_nama_user(); ?></option>

                                <?php } else { ?>

                                    <option value="<?php echo $value1->get_kd_d_kppn(); ?>"><?php echo $value1->get_kd_d_kppn(); ?> | <?php echo $value1->get_nama_user(); ?></option>

        <?php } ?>

                            <?php } ?>

                        </select>
                        <?php } ?>
<!--<<<<<< .mine-->
            <div class="row">
                <div class="col-md-6">
                    <label >Tanggal Mulai: </label>
                    <input class="form-control tanggal" type="text" name="d_tanggal1" id="d_tanggal1" value="<?php if (isset($this->d_tanggal1)) { echo $this->d_tanggal1; } ?>">
                    
    
                    <label>Status Awal:</label>
                    <select class="form-control" type="text" name="d_status1" id="d_status1">
                        <option value ="" selected>-- pilih --</option>
                         <?php foreach ($data as $row) { ?>
                        <option value="<?php echo $row?>" <?php if ($this->d_status1 == $row) { echo "selected"; }?>><?php echo $row?></option><?php }?>
                    </select>
                    
                </div>
                <div class="col-md-6">
                    <label >Tanggal Selesai </label>
                    <input class='form-control tanggal' type="text" name="d_tanggal2" id="d_tanggal2" value="<?php if (isset($this->d_tanggal2)) { echo $this->d_tanggal2; } ?>">
                    <label>Status Akhir:</label>
                    <select class="form-control" type="text" name="d_status2" id="d_status2">
                        <option value ="" selected>-- pilih --</option>
                         <?php foreach ($data as $row) { ?>
                        <option value="<?php echo $row?>" <?php if ($this->d_status2 == $row) { echo "selected"; }?>><?php echo $row?></option><?php }?>
                    </select>
                </div>
            </div>
                </div>
                <div class="modal-footer">
                    <button type="submit" name="submit_file" class="btn btn-primary" style="width: 100%" onClick="">Kirim</button>
                </div>

            </form>

        </div>

    </div>

</div> <!--end filter-->

<!-- Skrip -->
<script type="text/javascript" charset="utf-8">

    $(function(){
            hideErrorId();
            hideWarning();
            $("#tanggal_awal").datepicker({ startDate: '+1d' });
            $("#tanggal_akhir").datepicker({ startDate: '+1d' });
            $("#tanggal_1").datepicker({startDate: '+1d'});
            $("#tanggal_2").datepicker({dateFormat: "dd-mm-yy"});
            $("#d_tanggal1").datepicker({dateFormat: "dd-mm-yy"});
            $("#d_tanggal2").datepicker({dateFormat: "dd-mm-yy"});
        });
    function hideErrorId(){
        $('.error').fadeOut(0);
        }
    
    $(function() {
    $('input[name=status_pergantian]').on('click init-status_pergantian', function() {
        $('#permanenHide').toggle($('#Sementara').prop('checked'));
        $('#statusHide').toggle($('#Sementara').prop('checked'));
    }).trigger('init-status_pergantian');
    });
    
    //belum  berfungsi
    function toggle(stats) {
	var hideStats = document.getElementById('stats').value;
	if ( hideStats == '0' ) {
		document.getElementById('permanenHide1').style.display = 'none';
        document.getElementById('statusHide1').style.display = 'none';
	}
	else {
		document.getElementById('permanenHide1').style.display = '';
        document.getElementById('statusHide1').style.display = '';
	   }
    }
    
    function hideWarning() {
        
        $('#kdkppn').change(function() {
            if (document.getElementById('kdkppn').value != '') {
                $('#warning-all').fadeOut(200);
            }
        });
        
        $('#nip1').keyup(function() {
            if (document.getElementById('nip1').value != '') {
                $('#warning-all').fadeOut(200);
            }
        });
        
        $('#nip2').keyup(function() {
            if (document.getElementById('nip2').value != '') {
                $('#warning-all').fadeOut(200);
            }
        });
        
        $('#nama1').keyup(function() {
            if (document.getElementById('nama1').value != '') {
                $('#warning-all').fadeOut(200);
            }
        });
        
        $('#nama2').keyup(function() {
            if (document.getElementById('nama2').value != '') {
                $('#warning-all').fadeOut(200);
            }
        });
        
        $('#email1').keyup(function() {
            if (document.getElementById('email1').value != '') {
                $('#warning-all').fadeOut(200);
            }
        });
        
        $('#email2').keyup(function() {
            if (document.getElementById('email2').value != '') {
                $('#warning-all').fadeOut(200);
            }
        });
        
        $('#status1').change(function() {
            if (document.getElementById('status1').value != '') {
                $('#warning-all').fadeOut(200);
            }
        });
        
        $('#status2').change(function() {
            if (document.getElementById('status2').value != '') {
                $('#warning-all').fadeOut(200);
            }
        });
        
        $('#posisi1').change(function() {
            if (document.getElementById('posisi1').value != '') {
                $('#warning-all').fadeOut(200);
            }
        });
        
        $('#posisi2').change(function() {
            if (document.getElementById('posisi2').value != '') {
                $('#warning-all').fadeOut(200);
            }
        });
        
        $('#tanggal_awal').change(function() {
            if (document.getElementById('tanggal_awal').value != '') {
                $('#warning-all').fadeOut(200);
            }
        });
        
        $('#tanggal_akhir').change(function() {
            if (document.getElementById('tanggal_akhir').value != '') {
                $('#warning-all').fadeOut(200);
            }
        });
        
        $('#surat').keyup(function() {
            if (document.getElementById('surat').value != '') {
                $('#warning-all').fadeOut(200);
            }
        });
        
        $('#pdf_surat').change(function() {
            if (document.getElementById('pdf_surat').value != '') {
                $('#warning-all').fadeOut(200);
            }
        });
        
        $('#user_session').keyup(function() {
            if (document.getElementById('user_session').value != '') {
                $('#warning-all').fadeOut(200);
            }
        });
        
        $('#status_pergantian').keyup(function() {
            if (document.getElementById('status_pergantian').value != '') {
                $('#warning-all').fadeOut(200);
            }
        });
        
        $('#kdkppn0').change(function() {
            if (document.getElementById('kdkppn0').value != '') {
                $('#warning0').fadeOut(200);
            }
        });
        
        $('#nip_1').keyup(function() {
            if (document.getElementById('nip_1').value != '') {
                $('#warning0').fadeOut(200);
            }
        });
        
        $('#nip_2').keyup(function() {
            if (document.getElementById('nip_2').value != '') {
                $('#warning0').fadeOut(200);
            }
        });
        
        $('#nama_1').keyup(function() {
            if (document.getElementById('nama_1').value != '') {
                $('#warning0').fadeOut(200);
            }
        });
        
        $('#nama_2').keyup(function() {
            if (document.getElementById('nama_2').value != '') {
                $('#warning0').fadeOut(200);
            }
        });
        
        $('#email_1').keyup(function() {
            if (document.getElementById('email_1').value != '') {
                $('#warning0').fadeOut(200);
            }
        });
        
        $('#email_2').keyup(function() {
            if (document.getElementById('email_2').value != '') {
                $('#warning0').fadeOut(200);
            }
        });
        
        $('#status_1').change(function() {
            if (document.getElementById('status_1').value != '') {
                $('#warning0').fadeOut(200);
            }
        });
        
        $('#status_2').change(function() {
            if (document.getElementById('status_2').value != '') {
                $('#warning0').fadeOut(200);
            }
        });
        
        $('#posisi_1').change(function() {
            if (document.getElementById('posisi_1').value != '') {
                $('#warning0').fadeOut(200);
            }
        });
        
        $('#posisi_2').change(function() {
            if (document.getElementById('posisi_2').value != '') {
                $('#warning0').fadeOut(200);
            }
        });
        
        $('#tanggal_1').change(function() {
            if (document.getElementById('tanggal_1').value != '') {
                $('#warning0').fadeOut(200);
            }
        });
        
        $('#tanggal_2').change(function() {
            if (document.getElementById('tanggal_2').value != '') {
                $('#warning0').fadeOut(200);
            }
        });
        
        $('#surat0').keyup(function() {
            if (document.getElementById('surat0').value != '') {
                $('#warning0').fadeOut(200);
            }
        });

        $('#pdf_surat0').change(function() {
            if (document.getElementById('pdf_surat0').value != '') {
                $('#warning-0').fadeOut(200);
            }
        });
        
        $('#user_session0').keyup(function() {
            if (document.getElementById('user_session0').value != '') {
                $('#warning0').fadeOut(200);
            }
        });
        
        $('#status_pergantian0').keyup(function() {
            if (document.getElementById('status_pergantian0').value != '') {
                $('#warning0').fadeOut(200);
            }
        });

    }
    
    function cek_upload() {
        
        var v_nip1 = document.getElementById('nip1').value;
        var v_nip2 = document.getElementById('nip2').value;
        var v_nama1 = document.getElementById('nama1').value;
        var v_nama2 = document.getElementById('nama2').value;
        var v_email1 = document.getElementById('email1').value;
        var v_email2 = document.getElementById('email2').value;
        var v_posisi1 = document.getElementById('posisi1').value;
        var v_posisi2 = document.getElementById('posisi2').value;
        var v_tanggal_awal = document.getElementById('tanggal_awal').value;
        var v_tanggal_akhir = document.getElementById('tanggal_akhir').value;
        
        <?php if(Session::get('role') == UMADMIN){ ?>
        var v_status1 = document.getElementById('status1').value;
        var v_kdkppn = document.getElementById('kdkppn').value;
        <?php }?>
        var v_status2 = document.getElementById('status2').value;
        var v_surat = document.getElementById('surat').value;
        var v_pdf_surat = document.getElementById('pdf_surat');
        //var v_file = v_pdf_surat.files[0];

        var pattern = '^[0-9]+$';
        
        //var cek_surat = window.location.pathname("userSpan/cekSurat/")+ v_surat;
        
        var d = new Date('<?php echo date('M d, Y H:i:s') ?>');
        var n = d.getHours();
        
        /*if (cek_surat >= 0) { 
            
            $('#warning-all').html('Surat sudah pernah diinput');
            $('#warning-all').fadeIn(200);
            return false;
            
        }*/
        
        if (n >= 16) { 
            
            $('#warning-all').html('Maaf, Anda hanya dapat mengirim data sebelum pukul 16.00');
            $('#warning-all').fadeIn(200);
            return false;
            
        }
       
        <?php if(Session::get('role') == UMADMIN){ ?>
        if (v_kdkppn == '' || v_nip1 == '' || v_nip2 == '' || v_nama1 == '' || v_nama2 == '' || v_email1 == '' || v_email2 == '' || v_posisi1 == '' || v_posisi2 == '' || v_tanggal_awal == '' || v_status1 == '' || v_surat == '' || v_pdf_surat == '' || $('#pdf_surat').val() == '') {
            
            $('#warning-all').html('Isi semua parameter');
            $('#warning-all').fadeIn(200);
            return false;
            
        }
        <?php } else {?>
        if (v_nip1 == '' || v_nip2 == '' || v_nama1 == '' || v_nama2 == '' || v_email1 == '' || v_email2 == '' || v_posisi1 == '' || v_posisi2 == '' || v_tanggal_awal == '' || v_surat == '' || v_pdf_surat == '' || $('#pdf_surat').val() == '') {
            
            $('#warning-all').html('Isi semua parameter');
            $('#warning-all').fadeIn(200);
            return false;
            
        }
        <?php } ?>
        /* -- */
        
        var input, file;

        if (!window.FileReader) {
            $('#warning-all').html('Nampaknya browser Anda tidak didukung. Coba gunakan versi yang lebih baru.');
            $('#warning-all').fadeIn(200);
            return false;
        }

        input = document.getElementById('pdf_surat');
        
        if (!input) {
            $('#warning-all').html('Nampaknya browser Anda tidak didukung. Coba gunakan versi yang lebih baru.');
            $('#warning-all').fadeIn(200);
            return false;
        }
        else if (!input.files) {
            $('#warning-all').html('Nampaknya browser Anda tidak didukung. Coba gunakan versi yang lebih baru.');
            $('#warning-all').fadeIn(200);
            return false;
        }
        else if (!input.files[0]) {
            $('#warning-all').html('Nampaknya browser Anda tidak didukung. Coba gunakan versi yang lebih baru.');
            $('#warning-all').fadeIn(200);
            return false;
        }
        else {
            file = input.files[0];
            if ((file.size / 1024) > 512) {
                $('#warning-all').html('File surat yang Anda lampirkan melebihi batas maksimal 512KB.');
                $('#warning-all').fadeIn(200);
                return false;
            }
            
            var fileExtension = "";
            if (v_pdf_surat.value.lastIndexOf(".") > 0) {
                fileExtension = v_pdf_surat.value.substring(v_pdf_surat.value.lastIndexOf(".") + 1, v_pdf_surat.value.length);
            }
            if (fileExtension.toLowerCase() == "pdf") {
                return true;
            }
            else {
                $('#warning-all').html('File surat harus berformat PDF.');
                $('#warning-all').fadeIn(200);
                return false;
            }
        }
        
        /* -- */
        
        if ((v_nip1 != '' && v_nip1.length != 18) || (v_nip2 != '' && v_nip2.length != 18)) {
            $('#warning-all').html('NIP harus 18 digit');
            $('#warning-all').fadeIn(200);
            return false;

        }

        if (v_nip1 != '' && !v_nip1.match(pattern)) {
            var wsp2d = 'NIP harus dalam bentuk angka!';
            $('#warning-all').html(wsp2d);
            $('#warning-all').fadeIn(200);
            return false;
        }

        if (v_tgl_awal != '' && v_tgl_akhir != ''){
            if(v_tgl_awal > v_tgl_akhir){
                $('#warning-all').html('Tanggal awal tidak boleh lebih dari tanggal akhir');
                $('#warning-all').fadeIn(200);
                return false;
            }
        }
        
        if(v_tanggal_akhir < v_tanggal_awal){
            $('#warning-all').html('Tanggal akhir tidak bisa kurang dari tanggal awal');
            $('#warning-all').fadeIn(200);
            return false;
        }
        
        confirm("Anda yakin bahwa data yang telah Anda masukkan benar?<br>Anda tidak dapat mengganti data jika isian yang Anda kirim salah");

    }
    
    function cek_upload2() {
        
        var v_nip1 = document.getElementById('nip_1').value;
        var v_nip2 = document.getElementById('nip_2').value;
        var v_nama1 = document.getElementById('nama_1').value;
        var v_nama2 = document.getElementById('nama_2').value;
        var v_email1 = document.getElementById('email_1').value;
        var v_email2 = document.getElementById('email_2').value;
        var v_posisi1 = document.getElementById('posisi_1').value;
        var v_posisi2 = document.getElementById('posisi_2').value;
        var v_tanggal_awal = document.getElementById('tanggal_1').value;
        var v_tanggal_akhir = document.getElementById('tanggal_2').value;
        var v_status1 = document.getElementById('status_1').value;
        var v_status2 = document.getElementById('status_2').value;
        var v_surat = document.getElementById('surat0').value;
        var v_kdkppn = document.getElementById('kdkppn0').value;
        

        var pattern = '^[0-9]+$';
        
        if (v_kdkppn == '' || v_nip1 == '' || v_nip2 == '' || v_nama1 == '' || v_nama2 == '' || v_email1 == '' || v_email2 == '' || v_posisi1 == '' || v_posisi2 == '' || v_tanggal_awal == '' || v_tanggal_akhir == '' || v_status1 == '' || v_status2 == '' || v_surat == '') {
            
            $('#warning0').html('Isi semua parameter, cuy');
            $('#warning0').fadeIn(200);
            return false;
            
        }
        
        if ((v_nip1 != '' && v_nip1.length != 18) || (v_nip2 != '' && v_nip2.length != 18)) {
            $('#warning0').html('NIP harus 18 digit, dong!');
            $('#warning0').fadeIn(200);
            return false;

        }

        if (v_nip1 != '' && !v_nip1.match(pattern)) {
            var wsp2d = 'NIP harus dalam bentuk angka!';
            $('#warning0').html(wsp2d);
            $('#warning0').fadeIn(200);
            return false;
        }

        if (v_tgl_awal != '' && v_tgl_akhir != ''){
            if(v_tgl_awal > v_tgl_akhir){
                $('#warning0').html('Tanggal awal gak boleh lebih dari tanggal akhir');
                $('#warning0').fadeIn(200);
                return false;
            }
        }

    }

</script>